Skip to content

feat(bitgo): register Pearl in the coin factory - #9366

Merged
manojkumar138 merged 1 commit into
masterfrom
CECHO-1792-wire-pearl-coinfactory
Jul 28, 2026
Merged

feat(bitgo): register Pearl in the coin factory#9366
manojkumar138 merged 1 commit into
masterfrom
CECHO-1792-wire-pearl-coinfactory

Conversation

@manojkumar138

@manojkumar138 manojkumar138 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Wires the Pearl (Duplex) coin classes from @bitgo/sdk-coin-pearl into the bitgo module so bitgo.coin('pearl') and bitgo.coin('tpearl') resolve.

PR 3 of 3 — completes the BitGoJS onboarding after #9347 (statics) and #9360 (abstract-utxo + sdk-coin-pearl).

5 files, one signed commit.

Changes

File Change
src/v2/coinFactory.ts Pearl/Tpearl import; registerCoinConstructors entries; getCoinConstructor cases
src/v2/coins/index.ts import + re-export, so import { Pearl } from 'bitgo' works
package.json @bitgo/sdk-coin-pearl dependency
tsconfig.json project reference

Registered in both mechanisms — registerCoinConstructors (eager) and getCoinConstructor (lazy lookup). Missing the second would make Pearl resolve inconsistently depending on the code path.

Why the direct import, not the ./coins barrel

Pearl/Tpearl are imported straight from @bitgo/sdk-coin-pearl in coinFactory.ts, rather than via the ./coins barrel like most coins. Routing them through the barrel makes coinFactory observe a partially-initialised module, and unrelated constructors end up undefined at registration time:

TypeError: Cannot read properties of undefined (reading 'createInstance')
  at registerCoinConstructors (coinFactory.ts:279)   // <- TethLikeCoin, unrelated to Pearl

Isolated three-way comparison under identical local state:

Tree require('coinFactory.ts')
master + barrel ✅ loads
this PR + barrel TethLikeCoin undefined
this PR + direct import ✅ loads

Direct import is an established pattern in this file — Bcha/Tbcha, Near/TNear, AdaToken, SolToken, TrxToken and others are all imported from their packages directly rather than through the barrel.

The barrel still re-exports Pearl/Tpearl, so the public API surface matches every other coin.

Verification

barrel exports Pearl/Tpearl:      function function
getCoinConstructor('pearl')  ->   function
getCoinConstructor('tpearl') ->   function

bitgo builds clean; prettier and eslint clean (0 errors). Full dependency graph builds — 102 packages, zero TS errors.

Caveat on local test runs: I could not get modules/bitgo's unit suite to run end-to-end locally, but this is pre-existing and unrelated — on clean master the same entrypoint fails at FiatAED.createInstance, a different coin. The cause is stale untracked .js/.d.ts build artifacts shadowing .ts sources across the repo (this working tree has thousands). CI runs from a fresh checkout and is the authority here, so I'm relying on it for the full suite rather than reporting a local pass I didn't get.

While tracing that I also removed a stale leftover modules/sdk-coin-kas/ directory and four artifacts referencing the pre-rename @bitgo/sdk-coin-kas package name — all untracked, zero tracked files touched, not part of this commit.

Related

TICKET: CECHO-1792

🤖 Generated with Claude Code

@manojkumar138
manojkumar138 requested review from a team as code owners July 28, 2026 04:38
@linear-code

linear-code Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

CECHO-1792

@manojkumar138
manojkumar138 requested a review from Marzooqa July 28, 2026 04:38
Wire the Pearl (Duplex) coin classes from @bitgo/sdk-coin-pearl into the
bitgo module so `bitgo.coin('pearl')` and `bitgo.coin('tpearl')` resolve.
Completes the BitGoJS onboarding started in #9347 (statics) and #9360
(abstract-utxo + sdk-coin-pearl).

Registers in both mechanisms: registerCoinConstructors for eager
registration and getCoinConstructor for the lazy lookup.

Pearl and Tpearl are imported directly from @bitgo/sdk-coin-pearl rather
than through the ./coins barrel. Routing them through the barrel makes
coinFactory observe a partially initialised module and leaves unrelated
constructors such as TethLikeCoin undefined at registration time. Several
other coins in this file are imported directly for the same reason. The
barrel still re-exports Pearl/Tpearl so `import { Pearl } from 'bitgo'`
keeps working like every other coin.

Regenerate the Dockerfile with `yarn update-dockerfile` so the new module
is copied and linked for bitgo-express. This is generated content and the
dockerfile-check CI job diffs it, so it must be committed rather than
hand-edited.

TICKET: CECHO-1792

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@manojkumar138
manojkumar138 force-pushed the CECHO-1792-wire-pearl-coinfactory branch from 38e03b3 to 810dfbe Compare July 28, 2026 04:44
@manojkumar138
manojkumar138 requested a review from Copilot July 28, 2026 05:08
@manojkumar138

Copy link
Copy Markdown
Contributor Author

@claude review

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Claude finished @manojkumar138's task —— View job


Code Review for Pearl Coin Factory Registration ✅

Summary

This PR successfully wires the Pearl (Duplex) coin classes into the bitgo module coin factory. The implementation follows established patterns and correctly handles both mainnet (pearl) and testnet (tpearl) variants. The changes are minimal, well-structured, and consistent with existing coin registrations.

Review Findings

Excellent Implementation

1. Dual Registration Pattern

  • Correctly registers Pearl in both registerCoinConstructors (eager) and getCoinConstructor (lazy lookup) at coinFactory.ts:302 and coinFactory.ts:750
  • Proper testnet registration for tpearl at coinFactory.ts:368 and coinFactory.ts:882
  • This dual approach ensures consistent resolution regardless of code path

2. Direct Import Strategy

  • Smart use of direct imports from @bitgo/sdk-coin-pearl at coinFactory.ts:8 instead of barrel exports
  • This avoids the circular dependency issues described in the PR description
  • Follows established pattern used by other coins like Bcha, Near, etc.

3. Complete Integration

  • Package dependency properly added in package.json:103
  • TypeScript project reference added in tsconfig.json:212-214
  • Barrel export maintained in coins/index.ts:53 for public API consistency
  • Docker integration properly updated with COPY, link, and yarn link commands

4. Alphabetical Ordering

  • All additions maintain proper alphabetical ordering in their respective sections
  • Registration entries placed correctly between osmo and polygon

File-by-File Analysis

coinFactory.ts - Perfect implementation following BitGo patterns

  • Import placed alphabetically at line 8
  • Registration calls properly positioned in both functions
  • Consistent with existing coin constructor patterns

package.json - Clean dependency addition

  • Version ^1.0.0 is appropriate for new coin
  • Placement maintains alphabetical ordering

coins/index.ts - Correct barrel export pattern

  • Import and export maintain alphabetical order
  • Enables import { Pearl } from 'bitgo' as intended

tsconfig.json - Proper TypeScript integration

  • Project reference correctly added in alphabetical order
  • Enables proper module resolution and type checking

Dockerfile - Complete Docker integration

  • COPY command at line 145 for build stage
  • yarn link at line 250 for module linking
  • bitgo-express link at line 358 for runtime

🎯 Architecture Decisions

The PR author made excellent architectural decisions:

  1. Direct vs Barrel Imports: The choice to import directly from @bitgo/sdk-coin-pearl rather than through the ./coins barrel is well-justified and prevents module initialization issues.

  2. Consistent Patterns: All changes follow the exact patterns established by existing coins, ensuring maintainability.

  3. Complete Coverage: The implementation covers all necessary integration points without missing any components.

Security & Quality

  • No security concerns identified
  • No use of any types or unsafe practices
  • Follows TypeScript best practices
  • Maintains existing code style and conventions
  • No introduction of technical debt

Testing Considerations

The author notes local testing challenges due to build artifacts, which is reasonable. The implementation is straightforward enough that CI verification should be sufficient for this type of integration work.

Final Assessment

This is a high-quality implementation that demonstrates excellent understanding of the BitGoJS architecture. The code changes are minimal, targeted, and follow established patterns perfectly. The dual registration approach ensures robust coin resolution, and the direct import strategy shows thoughtful consideration of module initialization order.

Recommendation: ✅ APPROVE

The implementation is ready for merge and successfully completes the Pearl coin onboarding into BitGoJS.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR wires the Pearl coin implementations (pearl/tpearl) from @bitgo/sdk-coin-pearl into the modules/bitgo package so they can be constructed via the CoinFactory (including both eager registration and lazy lookup paths).

Changes:

  • Registers pearl and tpearl in registerCoinConstructors and adds getCoinConstructor switch cases.
  • Adds Pearl/Tpearl to the v2/coins barrel exports.
  • Adds the @bitgo/sdk-coin-pearl dependency and includes the package in the TS project references and Docker build/link steps.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
modules/bitgo/src/v2/coinFactory.ts Adds Pearl/Tpearl imports and registers constructors for both eager and lazy coin resolution paths.
modules/bitgo/src/v2/coins/index.ts Re-exports Pearl/Tpearl from the bitgo v2 coin barrel.
modules/bitgo/package.json Adds @bitgo/sdk-coin-pearl dependency.
modules/bitgo/tsconfig.json Adds TS project reference to ../sdk-coin-pearl.
Dockerfile Adds copy/link steps for sdk-coin-pearl in the container build flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Dockerfile
@manojkumar138
manojkumar138 merged commit 00e2e7c into master Jul 28, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants